138. 复制带随机指针的链表
为保证权益,题目请参考 138. 复制带随机指针的链表(From LeetCode).
解决方案1
Python
python
# 138. 复制带随机指针的链表
# https://leetcode-cn.com/problems/copy-list-with-random-pointer/
# Definition for a Node.
class Node:
def __init__(self, x: int, next: "Node" = None, random: "Node" = None):
self.val = int(x)
self.next = next
self.random = random
class Solution:
def copyRandomList(self, head: "Node") -> "Node":
pass
if __name__ == "__main__":
solution = Solution()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18